fittr provides a framework for fitting many formula-based models in parallel across multiple datasets and dependent variables.
In applied research, a typical project involves dozens of related regressions: multiple outcome variables, several model specifications, subsamples, and weighted/unweighted variants. fittr lets you declare your models, datasets, and definitions once, then generates every combination and runs them — optionally in parallel — returning a cleanly named nested list of fitted model objects.
Any modelling function that accepts formula, data, and weights arguments is supported: lm(), glm(), mixed-effects models, survival models, GAMs, and more.
Installation
# Install from Codeberg
pak::pak("codeberg::sam_crawley/fittr")Usage
library(fittr)
# Define model specifications
base <- model_spec(cyl, disp)
models <- list(
base = base,
extended = base |> add_terms(hp, wt),
reduced = base |> drop_terms(disp)
)
# Define dependent variables
defs <- list(
mpg = list(dv = "mpg", fun = "lm"),
qsec = list(dv = "qsec", fun = "lm")
)
# Preview what will run
preview_fit(models, mtcars, defs)
# Fit all combinations
results <- fit_models(models, mtcars, defs)
# Results are standard model objects
coef(results$mpg$extended)
summary(results$qsec$base)Key features
-
Multiple model specifications built compositionally from a shared base with
model_spec(),add_terms(),drop_terms(), and other helpers. - Multiple datasets — pass a named list of data frames; each model runs on every dataset.
-
Weighted regressions — supply
weight_varto run weighted and unweighted variants automatically. - Per-DV customisation — add extra terms, additional models, or modify specific models for individual dependent variables.
- Model-specific functions — use different estimators for different models within the same DV.
-
Models that need more than a formula — attach arguments for the fitting function (
set_args()) and formula sections after|, such as fixest’s fixed effects (add_part()). -
Parallel execution — powered by furrr/future, enabled with a single
workersargument. -
Preview before fitting —
preview_fit()shows every run as a tibble so you can verify formulas before committing.
Learn more
See vignette("fittr") for a detailed walkthrough.